import request from '@/plugins/axios.js';

// 获取文章评论列表
export const getComment = (params) => {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params,
    needToken: true,
  });
};

// 评论点赞
export const addCommentLike = (target) => {
  console.log(target);
  return request({
    method: 'post',
    url: '/v1_0/comment/likings',
    data: {
      target,
    },
    needToken: true,
  });
};

// 取消评论点赞
export const deleteCommentLike = (target) => {
  console.log(target);
  return request({
    method: 'delete',
    url: `/v1_0/comment/likings/${target}`,
    needToken: true,
  });
};

// 发布评论或评论回复
export const addComment = (data) => {
  return request({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target: data.target,
      content: data.content,
      art_id: data.art_id,
    },
    needToken: true,
  });
};
